﻿using MqttServerTest.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Threading.Tasks;

namespace MqttServerTest
{
    class Program
    {
        static async Task Main(string[] args)
        {
            Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            Console.WriteLine("Hello World!");
            var obg = new JsonObject
            {
                ["A"] = 10.21,
                ["B"] = 10.22,
                ["C"] = "10.23",
                ["D"] = 10.24,
                ["E"]=10
            };
            var s=obg.ToJsonString();
            var to=JsonSerializer.Deserialize<Test>(s);
            var d=Convert.ToDecimal(to.C);
            var tes = JsonSerializer.Serialize(new Test());
            Console.WriteLine(tes);

            Console.WriteLine("请选择运行模式");
            Console.WriteLine("1：服务器模式");
            Console.WriteLine("2：客户端模式");

            string topic = Console.ReadLine();
            switch (topic)
            {
                case "1":
                    {
                        MyServer mqttServer = new MyServer();
                        Console.Title = "Server";
                        await mqttServer.StartAsync();
                        Console.ReadLine();
                    }
                    break;
                case "2":
                    {
                        MyClient mqttClient = new MyClient();
                        Console.Title = "Client";
                        await mqttClient.StartAsync();

                        Console.ReadLine();

                    }
                    break;
            }



        }

    }
}
